#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/5/27 16:52
# @Author  : khz_df
# @Site    : 
# @File    : application.py
# @Software: ce9nt


import os


# def crack_captcha(captcha_image):
#     output = crack_captcha_cnn()
#
#     saver = tf.train.Saver()
#     with tf.Session() as sess:
#         saver.restore(sess, tf.train.latest_checkpoint('.'))
#
#         predict = tf.argmax(tf.reshape(output, [-1, MAX_CAPTCHA, CHAR_SET_LEN]), 2)
#         text_list = sess.run(predict, feed_dict={X: [captcha_image], keep_prob: 1})
#
#         text = text_list[0].tolist()
#         vector = np.zeros(MAX_CAPTCHA * CHAR_SET_LEN)
#         i = 0
#         for n in text:
#             vector[i * CHAR_SET_LEN + n] = 1
#             i += 1
#         return vec2text(vector)
from cnn import parse_captcha


def main():
    # text, image = gen_captcha_text_and_image()
    # image = convert2gray(image)
    # image = image.flatten() / 255
    # predict_text = crack_captcha(image)
    # print("正确: {}  预测: {}".format(text, predict_text))
    result_string = parse_captcha(r'N:\_TMP\captcha\4399_result_test\0.png', r'N:\_TMP\captcha\4399_result_model_path')
    print(result_string)


if __name__ == "__main__":
    print("------------------    Enter __main__    ------------------")

    print(u"[Current work directory is : ]\t" + os.getcwd())
    print(u"[Current process ID is : ]\t" + str(os.getpid()))
    print("\n")
    main()

    print("------------------    Leave __main__    ------------------")
